package com.sky.financelake.viewmodels.remote;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

import com.sky.financelake.bean.dto.QuotationDto;
import com.sky.financelake.bean.dto.SimpleDayKDto;
import com.sky.financelake.retrofit.ApiResponse;
import com.sky.financelake.retrofit.QuotationRepository;
import com.sky.financelake.viewmodels.BaseViewModel;

import java.util.List;

public class QuotationViewModel extends BaseViewModel {
    private MutableLiveData<ApiResponse<List<QuotationDto>>> mutableLiveData;
    private MutableLiveData<ApiResponse<List<SimpleDayKDto>>> dayKLiveData;
    private MutableLiveData<ApiResponse<List<SimpleDayKDto>>> combinationLiveData;
    private QuotationRepository quotationRepository;

    public QuotationViewModel() {
        if (mutableLiveData != null) {
            return;
        }
        quotationRepository = QuotationRepository.getInstance();
    }

    public QuotationRepository getQuotationRepository() {
        return quotationRepository;
    }

    public LiveData<ApiResponse<List<QuotationDto>>> getQuotationLiveData() {
        if (mutableLiveData == null) {
            mutableLiveData = new MutableLiveData<ApiResponse<List<QuotationDto>>>();
        }
        return mutableLiveData;
    }

    public LiveData<ApiResponse<List<SimpleDayKDto>>> getCombinationLiveData() {
        if (combinationLiveData == null) {
            combinationLiveData = new MutableLiveData<ApiResponse<List<SimpleDayKDto>>>();
        }
        return combinationLiveData;
    }

    public LiveData<ApiResponse<List<SimpleDayKDto>>> getThreeRedLiveData() {
        if (dayKLiveData == null) {
            dayKLiveData = new MutableLiveData<ApiResponse<List<SimpleDayKDto>>>();
        }
        return dayKLiveData;
    }

    public void getAllQuotationByCode(String code) {
        quotationRepository.getAllQuotationByCode(mutableLiveData, code);
    }


    public void getThreeRed() {
        quotationRepository.getThreeRed(dayKLiveData);
    }

    public void getCombinationResult(String combination) {
        quotationRepository.getCombinationResult(combinationLiveData,combination);
    }
}
